import { http } from "@/utils/http";

// 上传视频文件到服务器
export const uploadVideoFile = (file: File) => {
  const formData = new FormData();
  formData.append("file", file);

  return http.request("post", "/api/common/upload", {
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

// 获取视频列表接口返回类型
export type VideoListResponse = {
  code: number;
  msg: "string";
  time: string;
  data: {
    total: number;
    page: number;
    limit: number;
    list: {
      id: number;
      video_name: string;
      video_url: string;
    };
  };
};

// 获取视频列表
export const getVideoList = (page = 1, limit = 10, exhibitor_id?: number) => {
  return http.request("get", "/api/video/list", {
    params: {
      page,
      limit,
      exhibitor_id
    }
  });
};

// 上传视频
export const uploadVideo = (data: any) => {
  return http.request("post", "/api/video/apply", {
    data
  });
};

// 获取视频详情
export const getVideoDetail = (id: number, exhibitor_id?: number) => {
  return http.request("get", "/api/video/detail", {
    params: {
      id,
      exhibitor_id
    }
  });
};

// 更新视频
export const updateVideo = (data: any) => {
  return http.request("post", "/api/video/update", {
    data
  });
};

// 更改视频状态
export const updateVideoStatus = (data: any) => {
  return http.request("post", "/api/video/changeStatus", {
    data
  });
};
